﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.RBAC.Domain.Model;
using S.RBAC.Read.Api.Application.Command.JurisdictionCommand;

namespace S.RBAC.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class JurisdictionController : ControllerBase
    {
        protected readonly IMediator _mediator;

        public JurisdictionController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取权限信息列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<List<Jurisdiction>> GetAllJurisdiction([FromQuery]JurisdictionGetAllCommand command)
        {
            return _mediator.Send(command);
        }

        /// <summary>
        /// 获取单条权限信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<Jurisdiction> GetJurisdiction([FromQuery]JurisdictionSelectCommand command)
        {
            return _mediator.Send(command);
        }
    }
}
